﻿<UserControl x:Class="DotNetSimaticDatabaseProtokollerConfigurationTool.Windows.SubwindowTest"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:my="clr-namespace:DotNetSimaticDatabaseProtokollerLibrary;assembly=JFK-ProtokollerLibrary"
             xmlns:Converters="clr-namespace:JFKCommonLibrary.WPF.Converters;assembly=JFKCommonLibrary" d:DesignHeight="348"
             d:DesignWidth="800"
             Unloaded="UserControl_Unloaded"
             mc:Ignorable="d">
    <UserControl.Resources>
        <Converters:NullToFalseConverter x:Key="myNullToFalseConverter" />

    </UserControl.Resources>
    <Grid>
        <Button Name="cmdTest"
                Width="251"
                Height="25"
                Margin="22,62,0,0"
                HorizontalAlignment="Left"
                VerticalAlignment="Top"
                Click="cmdTest_Click"
                Content="Test Read of Data (without Storrage)"
                IsEnabled="{Binding ElementName=cmbTriggerConnection,
                                    Path=SelectedItem,
                                    Converter={StaticResource myNullToFalseConverter}}" />
        <ComboBox Name="cmbTriggerConnection"
                  Width="251"
                  Height="23"
                  Margin="22,36,0,0"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top"
                  VerticalContentAlignment="Center"
                  ItemsSource="{Binding Datasets,
                                        Source={x:Static my:ProtokollerConfiguration.ActualConfigInstance}}"
                  SelectedItem="{Binding ElementName=grdDatasets,
                                         Path=SelectedItem.TriggerConnection}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Name}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>
        <Label Width="110"
               Margin="12,12,0,0"
               HorizontalAlignment="Left"
               VerticalAlignment="Top"
               Content="Dataset" />
        <Button Name="cmdTestTriggers"
                Width="251"
                Height="25"
                Margin="22,124,0,0"
                HorizontalAlignment="Left"
                VerticalAlignment="Top"
                Click="cmdTestTriggers_Click"
                Content="Test Trigger Bits"
                IsEnabled="{Binding ElementName=cmbTriggerConnection,
                                    Path=SelectedItem,
                                    Converter={StaticResource myNullToFalseConverter}}" />
        <DataGrid Name="grdDatasetFields"
                  Margin="22,186,21,12"
                  AutoGenerateColumns="False"
                  CanUserAddRows="False"
                  CanUserDeleteRows="False"
                  CanUserReorderColumns="False"
                  CanUserResizeRows="False"
                  CanUserSortColumns="True"
                  ItemsSource="{Binding ElementName=cmbTriggerConnection,
                                        Path=SelectedItem.DatasetConfigRows}">
            <DataGrid.Columns>
                <DataGridTemplateColumn Width="Auto"
                                        Header="Database-Field"
                                        IsReadOnly="False"
                                        SortMemberPath="DatabaseField">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding DatabaseField}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Width="Auto"
                                        Header="PLC-Value"
                                        IsReadOnly="False"
                                        SortMemberPath="PLCTag.Value">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding PLCTag.Value}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>

        </DataGrid>
        <Label Width="110"
               Margin="506,36,0,0"
               HorizontalAlignment="Left"
               VerticalAlignment="Top"
               Content="Error:" />
        <Button Name="cmdTestWithStorrage"
                Width="251"
                Height="25"
                Margin="22,93,0,0"
                HorizontalAlignment="Left"
                VerticalAlignment="Top"
                Click="cmdTestWithStorrage_Click"
                Content="Test Read of Data (with Storrage)"
                IsEnabled="{Binding ElementName=cmbTriggerConnection,
                                    Path=SelectedItem,
                                    Converter={StaticResource myNullToFalseConverter}}" />
        <Button Name="cmdTestService"
                Width="187"
                Height="25"
                Margin="289,62,0,0"
                HorizontalAlignment="Left"
                VerticalAlignment="Top"
                Click="cmdTestService_Click"
                Content="Test as Service" />
        <TextBlock Name="textBlock1"
                   Width="187"
                   Height="83"
                   Margin="289,97,0,0"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   Text="With the upper Button, you test the Protocoller, like when you run it as a Windows Service! To Stop it, leave this Window!"
                   TextWrapping="Wrap" />
        <Border Height="120"
                Margin="516,60,21,0"
                VerticalAlignment="Top"
                BorderBrush="Black"
                BorderThickness="1">
            <TextBox Name="lblError"
                     HorizontalAlignment="Stretch"
                     VerticalAlignment="Stretch"
                     IsReadOnly="True"
                     Text=""
                     TextWrapping="Wrap" />
        </Border>
    </Grid>
</UserControl>
